package hotel.quartz.oversea.job.meituan;

import hotel.base.oversea.constant.CommonUrlConstants;
import hotel.base.oversea.constant.quartz.UrlSwitchsEnums;
import hotel.base.oversea.utils.DateUtil;
import hotel.base.oversea.utils.GsonUtils;
import hotel.base.oversea.utils.Result;
import hotel.base.oversea.utils.StringUtil;
import hotel.quartz.oversea.job.base.BaseJob;
import hotel.quartz.oversea.util.JobRestTemplateUtils;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * 第二版-独立房态定时器解析接口数据-判断是否发生变化
 *
 *
 * @description: Part Time Query Deal Status VSec Job
 * @author: qiuyy
 * @date: 2020-05-26 13:22
 * @version: V1.0
 */
@Slf4j
public class PartTimeQueryDealStatusVSecJob implements BaseJob {
    private String timestamp = "Ptqcsj"+String.valueOf(System.currentTimeMillis())+ StringUtil.getFourRandom();

    @Autowired
    RestTemplate restTemplate;

    /**
     * 2秒一次定时器 解析房态接口数据
     * @param jobExecutionContext
     */
    @Override
    @SneakyThrows
    public void execute(JobExecutionContext jobExecutionContext) {
        log.info("Part Time Query Deal Status VSec Job {} >>>>>>>> 独立房态定时器解析接口数据-判断是否发生变化 执行时间: {}", timestamp, DateUtil.getCurrTime());
        String url = CommonUrlConstants.CALLBACK_HOST + UrlSwitchsEnums.goodsPrice.JOB_QUERY_MT_STATUS_DEAL_VSEC.getValue();
        Map map = new HashMap();
        map.put("timestamp",timestamp);
        Result response = JobRestTemplateUtils.post(url, GsonUtils.GsonString(map), restTemplate);
        log.info("Part Time Query Deal Status VSec Job {} >>>>>>>> 独立房态定时器解析接口数据-判断是否发生变化 结束response: {},response={}",timestamp,response);

    }


}
